<?php
$rowPage = 5;
if (!empty ($_GET["pageN"])) {
	$pageN = $_GET["pageN"] - 1;
} else {
	$pageN = 0;
}
$q = '';
if (!empty ($_POST["q"]) && $_POST["q"] != "") {
	$q = $_POST["q"];
}
if (!empty ($_GET["q"]) && $_GET["q"] != "") {
	$q = $_GET["q"];
}
$where = "";
if ($q != '') {
	$qList = split(' ', $q);

	foreach ($qList as $value) {
		if ($where != "") {
			$where = $where . " and ";
		}
		$where = $where .
		"(Name LIKE '%$value%' or 
			Ort LIKE '%$value%' or 
			Adresse LIKE '%$value%' or 
			Beschreibung LIKE '%$value%' or 
			Aktivitat LIKE '%$value%' or
                        Kategorie LIKE '%$value%')";
	}

}
if (isset ($Setting) && $Setting != "") {
	if ($where != "")
		$where .= ' and ';
	$where .= " KategorieID=" . $Setting;
}
if ($where != "") {
	$where = " where " . $where;
}
$sql = "select * FROM firmaview $where LIMIT " . ($pageN * $rowPage) . ",$rowPage";
$_rd = mysql_query($sql, $_db_link);
$i = 0;
if ($_rd) {

	echo "<div class='searchDiv'><input type='text' id='q' name='q' value='$q' class='searchTxt' /><input type='submit' class='BootenLink' style='margin-top:-1px' value='" . LangTextOut("suchen") . "' /></div>";
	$paging = CreatPaging("firmaview", $pageN, "", $rowPage, $where);
	echo $paging;
	echo '<div class="list">';
	while ($daten = mysql_fetch_array($_rd, MYSQL_ASSOC)) {
		echo '<div class="listrow">';
		if ($daten["LogoID"] != NULL) {
			echo geFile($daten["LogoID"], "smallPic", "small/", 75, 75);
		}
		echo '<div class="listdata"><h3>' . $daten["Name"] . '</h3>';
		echo str_replace("*", "<img src='Admin/phpimages/star.gif' />", $daten["Kategorie"]) . '<br>';
		echo substr($daten["Beschreibung"], 0, 100) . '...';
		echo '</div>';
		echo '<div class="buttenDiv" style="float:right;margin:4px">
			<a class="BootenLink"
			href="index.php?tag=' . $tagID . '&page=FirmaView&MoudeTagID=' . $MoudeTagID . '&AbteilungID=' . $daten["AbteilungID"] . '">' . LangTextOut("MehrInfo") . '</a></div>';
		echo '</div>';
	}

	echo '</div>';
	echo $paging;
}

?>


	